//#include "udp_serverEcho.hpp"
//#include "udp_serverCmd.hpp"
#include "udp_svrToMulti.hpp"
#include <memory>
#include <cstdlib>

static void usage(std::string proc)
{
    std::cout << std::endl
              << "Usage: " << proc << " port" << std::endl
              << std::endl;
}

// 指定ip ==> INADDR_ANY[任意IP]
// ./udp_server ip port ==> ./udp_server port
//这样写：在命令行./运行时 不再允许手动输入ip了
//在构造函数那里维护用哪个ip
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        usage(argv[0]);
        exit(1);
    }

    // std::string ip = argv[1];
    // uint16_t port = atoi(argv[2]);

    uint16_t port = atoi(argv[1]);

    // std::unique_ptr<UdpServer> unqptrTosvr(new UdpServer(ip, port));
    std::unique_ptr<UdpServer> unqptrTosvr(new UdpServer(port));

    unqptrTosvr->initServer();
    unqptrTosvr->Start();

    return 0;
}
